home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!smryan
- From: smryan@netcom.com (@#$%!?!)
- Subject: Re: Can anyone solve this problem?
- Message-ID: <smryanDpuDDr.CKC@netcom.com>
- Organization: The Programmer formerly known as S M Ryan
- X-Newsreader: TIN [version 1.2 PL1]
- References: <4kosek$12q@usenet.kornet.nm.kr>
- Date: Sun, 14 Apr 1996 07:41:51 GMT
- Sender: smryan@netcom13.netcom.com
-
- : i can't understand what this problem exactly mean because i'm
- : not so friendly in english.
-
- : problem is: "write a function rightrot(x,n) that returns the
- : value of the integer x rotated to the right by
- : n bit positions."
-
- When you right-shift a value, the rightmost bits are discarded. When
- you right rotate, the bits are moved around to leftmost position. For
- an eight-bit value
- abcdefgh
- right shifting three bits gives you
- 000abcde or 111abcde
- right rotating gives you
- fghabcde
-
- Draw the picture, look at it, and the code should become obvious.
-
- --
- The Queen, amused, in quiet power, | smryan@netcom.com PO Box 1563
- will draw the son to darkenned bower. | Cupertino, California
- Her face is fair, her fragrance rare, | (xxx)xxx-xxxx 95015
- with woven webs for wayward flower. | I don't use no smileys
-